package com.qjs.shiro.test.permission;

import org.apache.shiro.authz.Permission;

public class MyPermission implements Permission{
	
	private String resourceId;
	
	private String oprator;
	
	private String instaceId;
	
	
	public MyPermission(){
		
	}
	
	@Override
	public String toString() {
		return "MyPermission [resourceId=" + resourceId + ", oprator=" + oprator + ", instaceId=" + instaceId + "]";
	}

	public MyPermission(String permissionStr){
		String[] str=permissionStr.split("\\+");
		this.setResourceId(str[1]);
		this.setOprator(str[2]);
		//this.setInstaceId(str[3]);
		System.out.println(this);
	}
	
	@Override
	public boolean implies(Permission p) {
		if(!(p instanceof MyPermission)) return false;
		MyPermission my=(MyPermission)p;
		if("user".equals(this.getResourceId())){
			return true;
		}
		return false;
	}

	public String getResourceId() {
		return resourceId;
	}

	public void setResourceId(String resourceId) {
		this.resourceId = resourceId;
	}

	public String getOprator() {
		return oprator;
	}

	public void setOprator(String oprator) {
		this.oprator = oprator;
	}

	public String getInstaceId() {
		return instaceId;
	}

	public void setInstaceId(String instaceId) {
		this.instaceId = instaceId;
	}
	
}
